home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / popdate.zip / PDIC.C < prev    next >
Text File  |  1992-07-10  |  6KB  |  173 lines

  1. /********************************************************************
  2.         PopDATE - INITIALIZATION CODE
  3.          (c) Copyright 1992 by Omega Point, Inc.
  4.            Author: Ratko V. Tomic
  5. *********************************************************************/
  6.  
  7. #include "cr.h"
  8. #include "lm.h"
  9.  
  10.  
  11. #define    STK_SZ (150)
  12. word isr_stk[STK_SZ+1];        /* Resident stack */
  13. extern word init_data_end;
  14.  
  15.  
  16. extern word hk_list[];    /* Hotkey list, defined in PDID.C */
  17. extern service();    /* Hotkey service in PD.C */
  18.  
  19. /************************************************************************
  20.   Signon messages are defined in the disposable-data module PDID.C
  21. *************************************************************************/
  22.  
  23. extern char signon_scr[];    /* Signon message */
  24. extern char first_msg[];     /* First signon message */
  25. extern byte hello_atr[],mono_atr[];
  26. extern char cal_box[];         /* Calendar pop-up box */
  27. extern char catc[],catm[];   /* Attributes for calendar box */
  28. extern char txtm[];         /* TSR text attributes (mono)  */
  29. extern char cal_atr[];         /* Active TSR attributes (default=color) */
  30. extern char already[];       /* Already loaded message */
  31. extern char unl_ok[];           /* TSR was unloaded message */
  32. extern char unl_err[];         /* Cannot unload message (not loaded last) */
  33. extern int use_lim;         /* Set to 0 if no move to LIM (/E switch)  */
  34. extern int quiet;         /* No waiting for a key on signon */
  35.  
  36. /************************************************************************
  37.     VARIABLES USED AT RESIDENT TIME
  38. *************************************************************************/
  39.  
  40. extern word *buf;    /* Buffer for screen save */
  41. extern int wdx,wdy;    /* Window sizes */
  42. extern int x0,y0;    /* Corner position for calendar */
  43. extern int mx,my;    /* Start for day of month cursor */
  44. extern int rvx,rvy;    /* Last highlighted day of month */
  45.  
  46. /*********************************************************************
  47.         DISPLAY SIGNON SCREENS
  48. **********************************************************************/
  49.  
  50.  
  51. signon()
  52. { byte *s=hello_atr;
  53.    if (vid_mode==7)
  54.      {
  55.      s=mono_atr;
  56.      }
  57.  
  58.    if (!quiet)
  59.      {
  60.      save_crs(); kil_crs();
  61.      crs_x=crs_y=0; vid_atr=7;
  62.      fil_scr('░');
  63.      crs_x=5; crs_y=1;
  64.      dspf(first_msg,s); 
  65.      pckey();
  66.      restore_crs();
  67.      }
  68.  
  69.    vid_atr=7; clr_scr();
  70.    crs_x=26; crs_y=4;
  71.    dspf(signon_scr,s);
  72.  
  73.    crs_x=0; crs_y=scr_len-1;
  74.    vid_atr=7;
  75.    dsp_hor(0x20,scr_width);
  76.    crs_x=0; crs_y--; mv_crs();
  77. }
  78.  
  79. /*********************************************************************
  80.       CONSTRUCT CALENDAR SCREEN 
  81.  
  82.  The code below builds calendar screen in a buffer which is used at
  83.  resident time by swap_blk() to put up the calendar and save the
  84.  foreground screen. To build the screen we use dspf() in a special
  85.  way: instead of displaying into video RAM we force it to "display"
  86.  in regular RAM by substituting temporarily the vid_seg variable.
  87. *********************************************************************/
  88.  
  89. bld_cal()
  90. { char *s;
  91.   word w,old_vseg;        /* Used to save old video segment */
  92.  
  93.     if (color)            /* Select screen colors    */
  94.       s=catc;
  95.     else            /* Select mono attributes */
  96.       {
  97.       s=catm;    
  98.       mem_cp(txtm,cal_atr,6);
  99.       }
  100.  
  101.     buf=(word*)_heap;        /* Space for screen buffer */
  102.     old_vseg=vid_seg;        /* Save real video segment */
  103.     w=((word)buf+15)>>4;    /* Align to next paragraph */
  104.     vid_seg=_cdata+w;        /* Create vid_seg in memory */
  105.     
  106.     crs_x=crs_y=0;
  107.     dspf(cal_box,s);        /* Display quickly calendar */
  108.     wdx=crs_x; wdy=crs_y+1;
  109.     rvx=mx=x0+3;        /* Cursor for days of month */
  110.     rvy=my=y0+1;
  111.     crs_x=crs_y=0;
  112.     get_blk(wdx,wdy,buf);    /* Compact the image */
  113.     _heap+=wdx*wdy*2;        /* Reserve space on heap */
  114.     vid_seg=old_vseg;        /* Restore video segment */
  115. }
  116.  
  117. /*****************************************************
  118.     LOAD TIME MAIN ENTRY
  119. ******************************************************/
  120.  
  121. main()
  122. { char *s;
  123.   int mtl=MOVE_BOTH;
  124.   
  125.      s=cmd_line;        /* Command line pinter */
  126.      up_case(s);
  127.      if (str_pos('H',s))    /* Switch /H - no check of high memory */
  128.        parent_data=0;        /* this skips himem scan for signature */
  129.  
  130.      if (str_pos('M',s))    /* Switch /M for mono color set */
  131.        color=0;
  132.  
  133.      if (str_pos('E',s))    /* Disable LIM use if /E present */
  134.          use_lim=0;
  135.      else if (is_stealth())
  136.     mtl=MOVE_CODE;
  137.      
  138.      if (str_pos('Q',s))    /* Quiet */
  139.        quiet=1;
  140.  
  141.      if (second_load())        /* Check if the TSR already loaded. */
  142.        {
  143.        if (str_pos('R',s)||str_pos('U',s))  /* Unload TSR      */
  144.          {
  145.      if (remove_tsr())        /* Remove TSR from memory */
  146.        dspf(unl_ok);        /* Inform about unloading */
  147.      else
  148.        dspf(unl_err);        /* Couldn't unload TSR due to  */
  149.                      /* another TSR loaded later    */
  150.          }
  151.        else dspf(already);        /* Otherwise show Help message */
  152.        mv_crs();            /* Reposition real cursor */
  153.        return(1);            /* Exit with errorlevel 1 */
  154.        }
  155.      bld_cal();                /* Construct calendar screen */
  156.  
  157. /** DISPLAY SIGNON SCREEN **/
  158.  
  159.      signon();
  160.  
  161. /** ENABLE TSR MODE **/
  162.  
  163.   stay_resident(isr_stk,STK_SZ*2); /* Define TSR stack, TSR on return */
  164.   idata_end=&init_data_end;       /* Enable init data disposal       */
  165.   icode_beg=(fp)signon;           /* Specify disposable code          */
  166.  
  167.   install_hk(hk_list,service,2*STK_SZ,3);  /* Install hot-keys. */
  168.   if (use_lim)
  169.      move_to_lim(1,1,mtl);           /*  Move TSR to LIM if available */
  170.  
  171.   return(0);            /* Set DOS errorlevel to 0 */
  172. }
  173.